<template>
	<view>
		<view class="content">
			<!-- 头部logo -->
			<view class="header">
				<image :src="logoImage"></image>
			</view>
			<!-- 一键登录 -->
			<button data-eventsync="true" class="login-button" @click="startLogin">一键登录</button>

			<view class="read-protocol">
				<radio color="#536AF4" style="transform:scale(0.7)" :checked="check" @click="protolClick"></radio>
				<text>
					已阅读并同意
					<text @click="handleUserAgrement" style="color: blue;">《用户协议》</text>和
					<text @click="handlePrivacy" style="color: blue;">《隐私协议》</text>
				</text>
			</view>
			<!-- 其他登录 -->
			<!-- <view class="other_login cuIcon">
				<view class="login_icon">
					<view class="cuIcon-weixin" @tap="login_weixin"></view>
				</view>
				<view class="login_icon">
					<view class="cuIcon-weibo" @tap="login_weibo"></view>
				</view>
				<view class="login_icon">
					<view class="cuIcon-github" @tap="login_github"></view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		login_user
	} from '@/common/login.js'
	export default {
		data() {
			return {
				//logo图片 base64
				logoImage: '',
				check: false,
				loginInfo: {
					encryptedData: '',
					sessionKey: '',
					iv: '',
					code: ''
				}
			}
		},
		methods: {
			//一键登录
			startLogin() {
				if (this.check) {
					var lg = this.loginInfo
					//1. 直接跳过测试
					uni.reLaunch({
						url: '/pages/tabbar/tabbar-1/tabbar-1'
					})
					
					getApp().globalData.userId = 1
					uni.setStorageSync('userid',getApp().globalData.userId) 
					//2. 测试抖音用户信息登录
					// tt.getUserProfile({
					// 	success(res) {
					// 		lg.encryptedData = res.encryptedData
					// 		lg.sessionKey = res.userInfo.sessionId
					// 		lg.iv = res.iv
					// 		tt.login({
					// 			force: true,
					// 			success(res2) {
					// 				lg.code = res2.code
					// 				//请求登录
					// 				login_user(lg).then(res=>{
					// 					//设置userId
					// 					getApp().globalData.userId = res.data.openId
					// 					uni.setStorageSync('userid',getApp().globalData.userId) 
					// 					uni.reLaunch({
					// 						url:'/pages/tabbar/tabbar-1/tabbar-1'
					// 					})
					// 				}).catch(err=>{
					// 					console.log(err)
					// 					uni.showModal({
					// 						title:'登录提示',
					// 						content:''+err.msg,
					// 						showCancel:false,
					// 					})
					// 				})
					// 			},
					// 			fail(res) {
					// 				console.log('登录失败');
					// 			},
					// 		});
					// 	},
					// 	fail(res) {
					// 		console.log("获取用户信息失败", res);
					// 	},
					// });
				} else {
					uni.showModal({
						title: '友情提示',
						content: '请勾选用户协议和隐私协议',
						showCancel: false,
					})
				}
			},
			protolClick() {
				this.check = !this.check
			},
			handleUserAgrement() {
				console.log('用户协议')
			},
			handlePrivacy() {
				console.log('隐私协议')
			}


		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-top: 10px;
		/* margin-top: 128rpx; */
	}

	/* 头部 logo */
	.header {
		width: 161rpx;
		height: 161rpx;
		box-shadow: 0rpx 0rpx 60rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 50%;
		background-color: #000000;
		margin-top: 128rpx;
		margin-bottom: 72rpx;
		margin-left: auto;
		margin-right: auto;
	}

	.header image {
		width: 161rpx;
		height: 161rpx;
		border-radius: 50%;
	}

	/* 主体 */
	.main {
		display: flex;
		flex-direction: column;
		padding-left: 70rpx;
		padding-right: 70rpx;
	}

	.tips {
		color: #999999;
		font-size: 28rpx;
		margin-top: 64rpx;
		margin-left: 48rpx;
	}

	/* 登录按钮 */
	.login-button {
		margin: 50rpx auto auto auto;
		background-color: #00cc99;
		border: 0rpx;
		border-radius: 2.5rem;
		text-decoration-color: "#FFFFFF";
		width: 80%;

		/* 字体 */
		font-size: 16px;
		font-weight: 500;
		letter-spacing: 0px;
		line-height: 38px;
		color: rgba(255, 255, 255, 1);
		text-align: center;
		vertical-align: top;
	}

	/* 其他登录方式 */
	.other_login {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		text-align: center;
	}

	.cuIcon {
		font-family: "cuIcon";
		font-size: inherit;
		font-style: normal;
	}

	.login_icon {
		border: none;
		font-size: 64rpx;
		margin: 0 64rpx 0 64rpx;
		color: rgba(0, 0, 0, 0.7)
	}


	.wechat_color {
		color: #83DC42;
	}

	.weibo_color {
		color: #F9221D;
	}

	.github_color {
		color: #24292E;
	}

	/* 底部 */
	.footer {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		margin-top: 64rpx;
		color: rgba(0, 0, 0, 0.7);
		text-align: center;
		height: 40rpx;
		line-height: 40rpx;
	}

	.footer text {
		font-size: 24rpx;
		margin-left: 15rpx;
		margin-right: 15rpx;
	}

	.read-protocol {
		display: flex;
		flex-direction: row;
		margin: 20rpx auto auto auto;
		width: 80%;
		font-size: 25rpx;
		color: #7b7b7b;
		align-items: center;
	}
</style>